home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 October / Enter 10 2006.iso / boot / isolinux / initrd / in / usr / lib / setup / kateosinstall.functs < prev    next >
Encoding:
Text File  |  2006-07-31  |  4.7 KB  |  148 lines

  1. #!/bin/sh
  2. # Copyright 2003  Slackware Linux, Inc.,  Concord, CA  USA
  3. #    All rights reserved.
  4. #
  5. # Redistribution and use of this script, with or without modification, is
  6. # permitted provided that the following conditions are met:
  7. #
  8. # 1. Redistributions of this script must retain the above copyright
  9. #    notice, this list of conditions and the following disclaimer.
  10. #
  11. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  12. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  14. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  17. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  18. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  19. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  20. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. #
  22.  
  23. # Hardly modified by Damian Rakowski for KateOS <maestromae@kateos.org>
  24. # - added dependency tracking
  25.  
  26. # globals
  27.  
  28. TMP=/var/log/setup/tmp
  29. SERIE=" a ap d doc g e l m n opt t tcl x xap xfce kde gnome miniiso"
  30. # functions
  31.  
  32. check_deps(){
  33. cat $1 | while read foo; do
  34.   if [ "$foo" != "" ]; then
  35.     if ! egrep "^$foo:" $TMP/TAGFILE 1>/dev/null 2>/dev/null; then
  36.     echo "$foo: ADD" >> $TMP/TAGFILE
  37.     for i in $SERIE ; do
  38.         if [ -r $MODEL/$i/$foo ]; then
  39.         check_deps $MODEL/$i/$foo 
  40.         fi 
  41.     done
  42.     fi
  43.   fi
  44.  done
  45. }
  46.  
  47. skip_rest(){
  48. for i in $SERIE ; do
  49.     if [ -d $MODEL/$i ]; then
  50.     for j in $MODEL/$i/* ; do
  51.         if [ ! -d $j ]; then
  52.         if ! egrep "^`basename $j`:" $TMP/TAGFILE 1>/dev/null 2>/dev/null ; then
  53.             echo "`basename $j`: SKP" >> $TMP/TAGFILE
  54.         fi
  55.         fi        
  56.     done
  57.     fi 
  58. done
  59. }      
  60.  
  61. install_package(){
  62. for category in $SERIE ; do
  63. if [ -d $SRCPATH/$category ]; then
  64.     # First, make sure there's at least one package:
  65.     if ! ls $SRCPATH/$category/*.tgz 1> /dev/null 2> /dev/null ; then
  66.       return 1
  67.     fi
  68.     for package in $SRCPATH/$category/*.tgz ; do
  69.     pk=`basename $package` 
  70.     pk=`package_name $pk`
  71.     if egrep -w "^$pk:" $TMP/TAGFILE 1>/dev/null 2>/dev/null; then    
  72.         installpkg -nodeps -force -root $ROOTDIR -infobox -tagfile $TMP/TAGFILE $package 
  73.         ERROR=$?
  74.     else
  75.     installpkg -nodeps -force -root $ROOTDIR -menu -priority OPT $package
  76.         ERROR=$?
  77.     fi    
  78.       if [ ! $ERROR = 0 ]; then
  79.         errorcode $ERROR $package
  80.       fi
  81.       
  82.             sed -e "/^$pk::*/d" $TMP/TAGFILE 1> $TMP/TAGFILEOUT
  83.             mv -f $TMP/TAGFILEOUT $TMP/TAGFILE
  84.     
  85.     done
  86.   fi 
  87. done  
  88. }
  89.  
  90.  
  91. package_name() {
  92.   STRING=`basename $1 .tgz`
  93.   # Check for old style package name with one segment:
  94.   if [ "`echo $STRING | cut -f 1 -d -`" = "`echo $STRING | cut -f 2 -d -`" ]; then
  95.     echo $STRING
  96.   else # has more than one dash delimited segment
  97.     # Count number of segments:
  98.     INDEX=1
  99.     while [ ! "`echo $STRING | cut -f $INDEX -d -`" = "" ]; do
  100.       INDEX=`expr $INDEX + 1`
  101.     done
  102.     INDEX=`expr $INDEX - 1` # don't include the null value
  103.     # If we don't have four segments, return the old-style (or out of spec) package name:
  104.     if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then
  105.       echo $STRING
  106.     else # we have four or more segments, so we'll consider this a new-style name:
  107.       NAME=`expr $INDEX - 3`
  108.       NAME="`echo $STRING | cut -f 1-$NAME -d -`"
  109.       echo $NAME
  110.     fi
  111.   fi
  112. }
  113.  
  114. errorcode() {
  115.   if [ $1 = 99 ]; then
  116.     # User aborted installation
  117.     exit 1
  118.   else
  119.     dialog --timeout 600 --title "`gettext setup "installpkg error"` #$1" --msgbox \
  120. "`gettext setup "There was a fatal error attempting to install"` $2.  `gettext setup "The package may \
  121. be corrupt, the installation media may be bad, or something else \
  122. has caused the package to be unable to be read without error.  You \
  123. may hit enter to continue if you wish, but if this is an important \
  124. required package then your installation may not work as-is."`" 11 70
  125.   fi
  126. }
  127.  
  128.  
  129. remount_disc() {
  130.   umount $DEVICE
  131.   eject $DEVICE
  132.   dialog --title "`gettext setup "INSERT NEXT DISC"`" --menu "`gettext setup "Please insert the next KateOS disc and \
  133. press ENTER to continue installing packages."`" \
  134. 10 62 2 \
  135.   "`gettext setup "Continue"`" "`gettext setup "Install packages from the next disc"`" \
  136.   "`gettext setup "Quit"`" "`gettext setup "Quit installing packages and finish up"`" 2> $TMP/reply
  137.   if [ ! $? = 0 ]; then
  138.     REPLY="`gettext setup "Quit"`"
  139.   else
  140.     REPLY="`cat $TMP/reply`"
  141.   fi
  142.   rm -f $TMP/reply
  143.   if [ "$REPLY" = "`gettext setup "Quit"`" ]; then
  144.     errorcode 99
  145.   fi;
  146.   mount $DEVICE $MOUNTPOINT 1> /dev/null 2> /dev/null
  147. }
  148.